<?php
namespace wechat;

class Classify extends Base
{

    /**
     * 自定义菜单创建  2017-10-15
     */
    public function publish($classify, $access_token, $attach = array())
    {
        $url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=$access_token";
       $result = httpdata($url, $classify);

        !isset($attach['uid']) && $attach['uid'] = 0;
        apilog($attach['uid'], 'wechat', 'classifypublish', $url, $classify, $result);
        return $result;
    }

    /**
     * 自定义菜单删除  2017-10-15
     */
    public function del($access_token, $attach = array())
    {
        $url = "https://api.weixin.qq.com/cgi-bin/menu/delete?access_token=$access_token";
        $result = https_request($url);

        !isset($attach['uid']) && $attach['uid'] = 0;
        apilog($attach['uid'], 'wechat', 'classifydel', $url, '', $result);
        return $result;
    }

    /**
     * 自定义菜单查询  2017-03-08
     */
    public function getclassify($access_token)
    {
        $url = "https://api.weixin.qq.com/cgi-bin/menu/get?access_token=$access_token";
        $result = https_request($url);
        return $result;
    }

    /**
     * 创建个性化菜单  2017-03-10
     */
    public function addconditional($classify, $access_token)
    {
        $url = "https://api.weixin.qq.com/cgi-bin/menu/addconditional?access_token=$access_token";
        $result = httpdata($url, $classify);
        return $result;
    }

    /**
     * 删除个性化菜单  2017-03-10
     */
    public function delconditional($menuid, $access_token)
    {
        $url = "https://api.weixin.qq.com/cgi-bin/menu/delconditional?access_token=$access_token";
        $result = httpdata($url, $menuid);
        return $result;
    }

    /**
     * 测试个性化菜单匹配结果 2017-03-10
     */
    public function match($userid, $access_token)
    {
        $url = "https://api.weixin.qq.com/cgi-bin/menu/trymatch?access_token=$access_token";
        $result = httpdata($url, $userid);
        return $result;
    }

    /**
     * 获取自定义菜单配置接口 2017-03-10
     */
    public function getmenuconfig($access_token)
    {
        $url = "https://api.weixin.qq.com/cgi-bin/get_current_selfmenu_info?access_token=$access_token";
        $result = https_request($url);
        return $result;
    }

}